﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Memo.Electricity.Game;
public class SelectLevel : MonoBehaviour
{
	private Button m_button;
	private Text m_text;
	private void Awake()
	{
		m_button = GetComponent<Button>();
		m_text = transform.Find("Text").GetComponent<Text>();
	}

	private void Start()
	{
		m_button.onClick.AddListener(LoadLevel);
	}

	//监听输入
	private void Update()
	{
		KeyCode keycode = m_text.text[7] - '0' + KeyCode.Alpha0;
		if (Input.GetKeyDown(keycode))
		{
			LoadLevel();

		}
	}


	private void LoadLevel()
	{
		//Get the level name
		string name = m_text.text;
		int major = name[5] - '0';
		int minor = name[7] - '0';
		//Load Scene
		Debug.Log(major + "," + minor);
		CLevelMgr.Inst.GoToLevel(major, minor);
	}
}
